//
//  MainTabBarViewController.m
//  四年
//
//  Created by 中软国际088 on 15/11/3.
//  Copyright © 2015年 小二. All rights reserved.
//

#import "MainTabBarViewController.h"
#import "MainNavigationController.h"
#import "SchoolViewController.h"
#import "DiaryViewController.h"
#import "FindViewController.h"
#import "MineViewController.h"
@interface MainTabBarViewController ()

@end

@implementation MainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initTabBarControllers];
   
}

//调用 添加分栏控制器 子控制器方法
-(void)initTabBarControllers{
    //校园标签
    SchoolViewController *school = [[SchoolViewController alloc] initWithItems:@[@"校园新闻", @"二手市场", @"失物招领"]];
    [self initTabBarViewController:school title:@"校园" normalImage:@"xinwen" selectedImage:@"xinwen2"];
    //日记标签
    DiaryViewController *diary = [[DiaryViewController alloc]init];
    [self initTabBarViewController:diary title:@"日记" normalImage:@"bi2" selectedImage:@"bi"];
    //发现标签
    FindViewController *find = [[FindViewController alloc]init];
    [self initTabBarViewController:find title:@"发现" normalImage:@"yanjing1" selectedImage:@"yanjing"];
    //我的标签
    MineViewController *mine = [[MineViewController alloc]init];
    [self initTabBarViewController:mine title:@"我的" normalImage:@"wo" selectedImage:@"wo1"];
}
//添加分栏控制器子控制器
-(void)initTabBarViewController:(UIViewController*)vc title:(NSString*)title normalImage:(NSString*)normalImage selectedImage:(NSString*)selectedImageName{
   
    //取消系统自带的渲染模式
    vc.tabBarItem.image = [[UIImage imageNamed:normalImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    //修改tabBar颜色
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithWhite:.834 alpha:1]} forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:Main_Color} forState:UIControlStateSelected];

    
    //添加导航栏
    MainNavigationController *navigation = [[MainNavigationController alloc]initWithRootViewController:vc];
    
    //添加标题
    vc.title = title;
    
    //子视图添加
    [self addChildViewController:navigation];
    
    
}

@end
